import 'package:dk_flutter_module_sale/sale/sale_in/map_tool/bean/bean_house_source_list.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class WidgetHouseSourceItem extends StatelessWidget {
  final  bool  hasHead;
  final  VoidCallback   houseSourceItemCallback;
  final  HouseSourceBean  houseSourceBean;
  WidgetHouseSourceItem({this.hasHead =true,this.houseSourceBean,this.houseSourceItemCallback});
  @override
  Widget build(BuildContext context) {

    String floor = "楼层："+ (houseSourceBean.storey!=null ? houseSourceBean.storey : "");
    String source = "来源："+(houseSourceBean.referenceSource!= null ? houseSourceBean.referenceSource : "");
    String createAt = "创建时间："+ (houseSourceBean.createdAt!= null ? houseSourceBean.createdAt : "");
    String price = "价格："+ (houseSourceBean.price!= null ? houseSourceBean.price.toString() : "")+"元/月";
    String area = "面积："+ (houseSourceBean.area!= null ? houseSourceBean.area.toString() : "")+"m²";
    String bd = "BD："+(houseSourceBean.dealerName!= null ? houseSourceBean.dealerName : "");
    return GestureDetector(
      onTap: (){
        if(houseSourceItemCallback!= null) {
          houseSourceItemCallback();
        }
      },
      child: Column(
        children: <Widget>[
          Offstage(
            child: Container(
              height: 10,
              color: Color(0xfff7f8f9),
            ),
            offstage: !hasHead,
          ),
          Container(
            color: Colors.white,
            padding: EdgeInsets.only(left: 16,top: 20,bottom: 15),
            child: Column(
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Text(houseSourceBean.id!=null? ("#"+houseSourceBean.id.toString()) : "",textAlign:TextAlign.left ,style: TextStyle(color: Color(0xff333333),fontSize: 14),),
                    Spacer(),
                  ],
                ),
                SizedBox(height: 10,),
                Row(
                  children: <Widget>[
                    Text(houseSourceBean.communityName!=null ? houseSourceBean.communityName : "",textAlign:TextAlign.left ,style: TextStyle(color: Color(0xff666666),fontSize: 12),),
                    Spacer(),
                  ],
                ),
                SizedBox(height: 9,),
                getRowWidget(area, price),
                SizedBox(height: 6,),
                getRowWidget(floor, source),
                SizedBox(height: 6,),
                getRowWidget(bd, createAt),

              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget getRowWidget(String str1, String str2) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        Container(
            width: 100,
            color: Colors.white,
            child:Text(str1,textAlign:TextAlign.left,style: TextStyle(color: Color(0xff666666),fontSize: 12),),
          ),
        SizedBox(width: 75,),
        Text(str2,textAlign:TextAlign.left,style: TextStyle(color: Color(0xff666666),fontSize: 12),),
      ],
    );
  }
}